***JOP Kane, Mason, and Wronski****
***SUPPLEMENTAL VOTER STUDY GROUP ANALYSES  */


*LONG FORM DATA ANALYSES
use "JOP_KMW_Panel_Long.dta"

xtsum pid // 20911 obs, 8000 groups:  the within group (i.e., within-person) SD for PID is .56

*Cronbach's alpha and pairwise correlation
alpha GaysLesbiansFT MuslimFT HispFT JewishFT BlackFT, item
alpha WhiteFT ChristiansFT, item

pwcorr DParty_stand RParty_stand, sig

*Figure E1 Model
xtreg pid RParty_stand DParty_stand i.timepoint, fe  i(case_identifier) // 1 SD increase predicts about .07 (.05) increase(decrease) on the PID scale
estimates store fe

*Figure E1 Graph
	*Panel A:  Democratic coalition graph
		*Note:  Some graph features changed using Graph Editor

margins, at(DParty_stand=(-3.25 (.25) 1.75))
marginsplot, xdimension(DParty_stand) recast(line) recastci(rarea) ///
ylabel (3 (1) 5) xlabel (-3 (1) 1) scheme(tufte) graphregion(margin(small)) ///
addplot(hist DParty_stand, legend(off) title( " ") ytitle("Party Identification", size(med)) xtitle("Affect Toward Democratic Groups (SD Units)", size(med)) ///
yaxis(2) yscale(alt axis(2)) percent ylabel(1 "1%" 2 "2%" 3 "3%" 4 "4%" 5 "5%" 6 "6%" 7 "7%" 8 "8%" 9 "9%" 10 "10%", labcolor(black*.9) axis(2)) ///
ytitle("Percent of Sample", axis(2) orientation(rvertical))  fcolor(white%10) lcolor(black)) 

	*Panel B:  Republican coalition graph
		*Note:  Some graph features changed using Graph Editor
margins, at(RParty_stand=(-3.6 (.2) 1.2))
marginsplot, xdimension(RParty_stand) recast(line) recastci(rarea) ///
ylabel (3 (1) 5) xlabel (-3 (1) 1) scheme(tufte) graphregion(margin(small)) ///
addplot(hist RParty_stand, legend(off) title( " ") ytitle("Party Identification", size(med)) xtitle("Affect Toward Republican Groups (SD Units)", size(med)) ///
yaxis(2) yscale(alt axis(2)) percent ylabel(1 "1%" 2 "2%" 3 "3%" 4 "4%" 5 "5%" 6 "6%" 7 "7%" 8 "8%" 9 "9%" 10 "10%", labcolor(black*.9) axis(2)) ///
ytitle("Percent of Sample", axis(2) orientation(rvertical))  fcolor(white%10) lcolor(black))

*Hausmann LR Test
xtreg pid RParty_stand DParty_stand, re // a random effects model yields far larger coefficients, but the hausman LR test is significant
estimates store re
hausman fe re  

*Table E1, Model 2
xtreg pid RParty_stand DParty_stand faminc ideo polint01 i.timepoint, fe  i(case_identifier)

*Table E1, Model 3
xtreg pid MuslimFT_stand GaysLesbiansFT_stand HispFT_stand BlackFT_stand JewishFT_stand ///
WhiteFT_stand ChristiansFT_stand i.timepoint, fe



*WIDE FORM DATA ANALYSES
use "JOP_KMW_Panel_Wide.dta"

*Figure E2 Model

reg pid7_2017_clean pid7_baseline_clean RelativeChange2011_16_stand RParty11  DParty11 ///
i.educ_baseline i.race_baseline i.religpew_baseline age_baseline female_baseline KnowLGBT_2011 ///
faminc_baseline_clean revpolinterest_baseline c.pid7_baseline_clean#c.revpolinterest_baseline, robust
	
margins, at(RelativeChange2011_16_stand=(-3(.2) 3)) atmeans

*Figure E2
	*Note:  Some graph features changed using Graph Editor
marginsplot, xdimension(RelativeChange2011_16_stand) recast(line) recastci(rarea) ///
ylabel (3 (1) 5) xlabel (-2 (1) 2) scheme(tufte) graphregion(margin(small)) ///
addplot(hist RelativeChange2011_16_stand, legend(off) title( " ") ytitle("Party Identification (2017)", size(med)) xtitle("∆ Republican Affect - ∆ Democratic Affect (2011->2016; SD Units)", size(medsmall)) ///
yaxis(2) yscale(alt axis(2)) percent ///
ylabel(1 "1%" 2 "2%" 3 "3%" 4 "4%" 5 "5%" 6 "6%" 7 "7%" 8 "8%" 9 "9%" 10 "10%" 11 "11%" 12 "12%" 13 "13%" 14 "14%" 15 "15%", labcolor(black*.9) axis(2)) ///
ytitle("Percent of Sample", axis(2) orientation(rvertical))  fcolor(white%10) lcolor(black))


*Placebo Test
reg RelativeChange2011_16_stand pid7_change1617 ///  B1 is indeed non-significant (p=.67)
pid7_baseline_clean  RParty11  DParty11 ///
i.educ_baseline i.race_baseline i.religpew_baseline age_baseline female_baseline KnowLGBT_2011 ///
faminc_baseline_clean revpolinterest_baseline c.pid7_baseline_clean#c.revpolinterest_baseline, robust


*********************************************
*********************************************
